<template>
	<d2-container>
		<el-form ref="form" :model="user" label-width="100px">
			<p>{{ user.name }}</p>
			<el-form-item label="密码">
			    <el-input v-model="user.password" placeholder="密码"></el-input>
			</el-form-item>
			<el-form-item>
			    <el-button type="primary" @click="submit()">保存</el-button>
			</el-form-item>
		</el-form>
	</d2-container>
</template>

<script>
import querystring from "querystring";
import request from "@/plugin/axios/index";
export default {
  created() {
    this.user.userid = this.$route.params.id;
    this.getUser();
  },
  data() {
    return {
      user: {
        userid: 0,
        password: "",
      },
    };
  },
  methods: {
    submit() {
      request
        .put(`/user/${this.user.userid}`, {
          password: this.user.password,
        })
        .then((res) => {
          this.$message.success("修改成功");
        });
    },
    getUser() {
      request
        .get(`/user/${this.user.userid}`)
        .then((res) => {
          this.user = res.user;
        })
        .catch((err) => {
          this.$message.warning(err);
        });
    },
  },
};
</script>
